﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;

/// <summary>
/// Summary description for StockKeyFigure
/// </summary>
public class StockKeyFigure
{
  private const string SP = "StockKeyFigures_GetById";
  DatabaseManager db;
  MySqlDataReader reader;

  public string Id { get; set; }
  public int Year { get; set; }
  public double KI { get; set; }
  public double PE { get; set; }
  public double EPS { get; set; }
  public double PEGRatio { get; set; }
  public double DividendPrShare { get; set; }
  public double DividendPrStockPrice { get; set; }


	public StockKeyFigure()
	{
    db = new DatabaseManager();
	}

  public void Load(string id, int year)
  {
    db.AddParameter("@id", id);
    db.AddParameter("@year", year);
    using (reader = db.ExecuteStoredProcedure(SP))
    {
      while (reader.Read())
      {
        Id = reader["id"].ToString();
        Year = Convert.ToInt32(reader["year"].ToString());
        KI = Convert.ToDouble(reader["KI"].ToString());
        PE = Convert.ToDouble(reader["PE"].ToString());
        EPS = Convert.ToDouble(reader["EPS"].ToString());
        PEGRatio = Convert.ToDouble(reader["PEG_ratio"].ToString());
        DividendPrShare = Convert.ToDouble(reader["dividend_pr_share"].ToString());
        DividendPrStockPrice = Convert.ToDouble(reader["dividend_pr_stock_price"].ToString());
      }
    }
  }
}